
######################### Getting outputs used for plotting balances ###########################
# Balance, allowing for treatment reversal Greens West
balance_greens_west_entry <- list() # this list stores ATT for W Entry
for (i in 1:length(greens_west_entry)){
    if(grepl("no ", names(greens_west_entry)[i])) {
        # if refinement is not used, then we let the balance
        # function use *equal weights* - a.k.a not really refining for anything
        use.equal.weights <- T
    } else {
        use.equal.weights <- F
    }
    
    balance_greens_west_entry[[i]] <-
        get_covariate_balance(matched.sets = greens_west_entry[[i]][1]$att,# att or atc
                              data = btw_west, 
                              covariates = covariates_greens_west, 
                              use.equal.weights = use.equal.weights)  
    
}


# naming the lists
names(balance_greens_west_entry) <- names(greens_west_entry)


# Balance, allowing for treatment reversal Greens East
balance_greens_east_entry <- list() # this list stores ATT for W Entry
for (i in 1:length(greens_east_entry)){
    if(grepl("no ", names(greens_east_entry)[i])) {
        # if refinement is not used, then we let the balance
        # function use *equal weights* - a.k.a not really refining for anything
        use.equal.weights <- T
    } else {
        use.equal.weights <- F
    }
    
    balance_greens_east_entry[[i]] <-
        get_covariate_balance(matched.sets = greens_east_entry[[i]][1]$att,# att or atc
                              data = btw_east, 
                              covariates = covariates_east, 
                              use.equal.weights = use.equal.weights)  
    
}

# naming the lists
names(balance_greens_east_entry) <- names(greens_east_entry)


## Putting SS and Ace together, allowing for treatment reversal 
# att
all_entry <- list("L1_West" = balance_greens_west_entry[substr(names(balance_greens_west_entry), start = 1, stop = 1)=="1"],
                 "L3_West" = balance_greens_west_entry[substr(names(balance_greens_west_entry), start = 1, stop = 1)=="3"],
                 "L1_East" = balance_greens_east_entry[substr(names(balance_greens_east_entry), start = 1, stop = 1)=="1"],
                 "L3_East" = balance_greens_east_entry[substr(names(balance_greens_east_entry), start = 1, stop = 1)=="3"]
)

save.image(file='data/tmp/PanelMatch_temp1.RData')


